package com.iisigroup.audf.statistics;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.iisigroup.log.statistics.FileProcessTest;

public class TestClass {
    private static Logger logger = LoggerFactory.getLogger(TestClass.class);
    /**
     * @param args
     */
    public static void main(String[] args) {
	
	String str01 ="300x250,468x60,300x400v(480x320,768x1024,100x100),400x300v,640x480v(200x200,728x90)";
	String str02 = "09007030,Lienchiang County\\,R,";
	StringUtils.split(str02,"");
	String reg01= ",(?![^(]*\\))";
	String reg02= ",(?![^Lienchiang County\\,R])";
	String[] data1 = str01.split(reg01);
	String[] data2 = str02.split(reg02);
	System.out.println(data1.length);
	System.out.println(data2.length);
    }
    
    public static void test01(){
	String str = "09007030,Lienchiang County\\, Fukien\\, R.O.C.,";
	String sample01 ="AUXLRL1405151503480863,TXXLRL1405151503252293,RL,20140515150348000,TKXLRL1405151503480293,T,RL02A70,國民身分證請領記錄查詢,Rl02a70ServiceImpl,doQuery,QUERY,2,AE-0101-S,處理完畢,10016010,10016010,10016010,RX0100015,方耀燦,195.16.1.27,57,X120099271,0,\\ ,\\ , ,F,R,";
	Pattern p = Pattern.compile(".*(?<=program)creek.*");
	Matcher m = p.matcher(sample01);
	 
	if(m.matches()){
		System.out.println("Match!");
	}else{
		System.out.println("No");
	}
	byRegExpr(sample01);
    }
    public static String[] byRegExpr(String line ){
	final String patternStr = "([\\s|\\w|\\.]*\\\\,[\\s|\\w|\\.]*)";
	final Pattern pattern = Pattern.compile(patternStr);
	final Matcher matcher = pattern.matcher(line);
	final List<String> metadata = new ArrayList<String>();
	while(matcher.find()){
	    final int groupCount = matcher.groupCount();
	    for(int i = 0 ; i<=groupCount ;++i){
		final String unit = matcher.group(i);
		logger.info("group:{} value :{}",i,unit);
	    }
//	    String unit = matcher.group(0);
//	    metadata.add(unit);
//	    logger.info(unit);
	}
	String[] result = metadata.toArray(new String[]{});
	return result;
    }

}
